package io.awen.modules.sign.controller;

import io.awen.common.exception.RRException;
import io.awen.common.utils.PageUtils;
import io.awen.common.utils.R;
import io.awen.modules.sign.entity.SignCarWeightChangeEntity;
import io.awen.modules.sign.entity.SignTaskOperationEntity;
import io.awen.modules.sign.qo.SignCarQo;
import io.awen.modules.sign.qo.SignCarWeightChangeQo;
import io.awen.modules.sign.qo.SignTaskQo;
import io.awen.modules.sign.service.SignCarWeightChangeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 车辆超速报警信息记录表
 */
@RestController
@RequestMapping("sign/signCarWeightChange")
public class SignCarWeightChangeController {
    @Autowired
    private SignCarWeightChangeService signCarWeightChangeService;

    /**
     * 分页查询
     */
    @RequestMapping("/list") //sign/signCarWeightChange/list
    public R list(@RequestBody SignCarWeightChangeQo qo) {
        PageUtils page = signCarWeightChangeService.queryPage(qo);
        return R.ok().put("page", page);
    }

    @ApiOperation("司机提交动作")
    @PostMapping("/submit")
    public R submit(@RequestBody SignCarWeightChangeEntity qo){
        signCarWeightChangeService.submit(qo);
        return R.ok();
    }


    /**
     * 台账
     */
    @RequestMapping("/ledger")
    public R ledger(@RequestBody SignCarWeightChangeQo qo) {
        PageUtils page = signCarWeightChangeService.queryLedger(qo);
        return R.ok().put("page", page);
    }
    /**
     * 按条件查询 各容器 处理的总收运量
     * @param qo
     * @return
     */
    @PostMapping("/weightTotalGroupByContainer")
    public R weightTotalGroupByContainer(@RequestBody SignCarWeightChangeQo qo){
        List<Map<String, Object>> mapList = signCarWeightChangeService.weightTotalGroupByContainer(qo);
        return R.ok().put("list", mapList);
    }

    /**
     * 总单查询
     * @param params
     */
    @RequestMapping("/totalTable")
    public R totalTable(@RequestBody SignCarWeightChangeQo qo) {
        PageUtils page = signCarWeightChangeService.totalTable(qo);
        return R.ok().put("page", page);
    }

    /**
     * 按条件查询 各车辆 处理的总收运量
     *
     * @param qo
     * @return
     */
    @PostMapping("/weightTotalGroupByCar") //sign/signtask/weightTotalGroupByCar
    public R weightTotalGroupByCar(@RequestBody SignCarWeightChangeQo qo) {
        List<Map<String, Object>> mapList = signCarWeightChangeService.weightTotalGroupByCar(qo);
        return R.ok().put("list", mapList);
    }

    @PostMapping("/queryPageWeightTotalGroupByCar") //sign/signtask/weightTotalGroupByCar
    public R queryPageWeightTotalGroupByCar(@RequestBody SignCarWeightChangeQo qo) {
        PageUtils pageUtils = signCarWeightChangeService.queryPageWeightTotalGroupByCar(qo);
        return R.ok().put("page", pageUtils);
    }

    @PostMapping("/weightTotalGroupByTimeLength")
    public R weightTotalGroupByTimeLength(@RequestBody SignCarWeightChangeQo qo) {
        List<Map<String, Object>> mapList = signCarWeightChangeService.weightTotalGroupByTimeLength(qo);
        return R.ok().put("list", mapList);
    }

}
